/*
 * @Author: funlee
 * @Email: i@funlee.cn
 * @Date: 2018-05-06 10:38:21
 * @Description: 通用的惰性单例
 */
var getSingle = function (fn) {
  var result;
  return function () {
    return result || (result = fn.apply(this, arguments))
  }
}

var createLoginLayer = function () {
  var div = document.createElement('div');
  div.innerHTML = '我是登录悬浮框';
  div.style.display = 'none';
  document.body.appendChild(div);
  return div;
}

var createSingleLoginLayer = getSingle(createLoginLayer);

document.querySelector('body').onclick = function () {
  console.log(123)
  var loginLayer = createSingleLoginLayer();
  loginLayer.style.display = 'block';
}